<template>
	<view class="unitRegister">
		<view class="unitRegister-title ff-font-25 ff-color-222 ff-font-weight-600">社会单位</view>
		<u-input height="88" placeholder="请输入单位社会信用代码" :custom-style="customStyle" v-model="socialCode" border="true" />
		<view class="ff-margin-top-20 unitRegister-but"><u-button type="primary" shape="circle" @click="nextClick">下一步</u-button></view>
		<view class="unitRegister-otherReg ff-text-center ff-font-13">
			无统一社会信用代码？
			<text @click="otherRegClick">请点击</text>
		</view>
		<f-loading ref="loading" />
		<u-toast ref="uToast" />
	</view>
</template>

<script>
export default {
	name: 'unitRegister',
	data() {
		return {
			customStyle: {
				'font-size': '30rpx'
			},
			socialCode: '' // 社会信用代码
		};
	},
	methods: {
		// 点击下一步
		nextClick() {
			if (!this.socialCode) {
				this.$refs.uToast.show({
					title: '请输入单位社会信用代码',
					type: 'error'
				});
				return;
			}
			this.$refs.loading.openLoading('查询中···'); // 打开loading动画
			this.$http
				.get({
					url: `/sys/user/validOrganizationCode/${this.socialCode}`
				})
				.then(res => {
					// console.log('社会信用代码校验结果----', res.data);
					if (res.data) {
						this.$refs.loading.closeLoading(); // 关闭loading动画
						this.$pageJump.navigateTo('/pages/loginRegister/register/socialUnit/unit/unitRegisterResult?code=' + this.socialCode);
					} else {
						this.$refs.loading.closeLoading(); // 关闭loading动画
						this.$refs.uToast.show({
							title: '社会信用代码填写不正确，请核实后再试',
							type: 'error'
						});
					}
				});
		},
		// 跳转到非正规社会信用代码注册
		otherRegClick() {
			this.$pageJump.navigateTo('/pages/loginRegister/register/socialUnit/unit/unitRegisterOther');
		}
	},
	onShareAppMessage() {
		return {
			title: '分享小程序给朋友',
			path: '/pages/homePage/Home'
		};
	}
};
</script>

<style lang="scss">
page {
	background-color: #ffffff;
}
.unitRegister {
	padding: 130rpx 72rpx 56rpx 72rpx;
	&-title {
		margin-bottom: 52rpx;
	}
	&-but {
		/deep/.u-size-default {
			height: 90rpx !important;
			line-height: 90rpx !important;
		}
	}
	&-otherReg {
		position: fixed;
		left: 0;
		bottom: 7%;
		width: 100%;
		color: #1b315e;
		text {
			color: #3178ff;
		}
	}
}
</style>
